{% extends "base.html" %}
{% load navigation_tags %}
{% load authorization_tags %}
{% block content %}
    {{ block.super }}
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading tight">
                    <h3 class="has-filters">
                        Tool Configurations
                        <div class="dropdown pull-right">
                            {% if "dojo.add_tool_configuration"|has_configuration_permission:request %}
                            <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1"
                                    data-toggle="dropdown" aria-expanded="true" aria-label="Tool configuration options">
                                <span class="fa-solid fa-screwdriver-wrench"></span>
                                <span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right" role="menu"
                                aria-labelledby="dropdownMenu1">
                                    <li role="presentation">
                                        <a href="{% url 'add_tool_config' %}">
                                            <i class="fa-solid fa-plus"></i> Add Tool Configuration
                                        </a>
                                    </li>
                            </ul>
                            {% endif %}
                        </div>
                    </h3>
                </div>

            </div>
            {% if confs %}

                <div class="clearfix">
                    {% include "dojo/paging_snippet.html" with page=confs page_size=True %}
                </div>
                <div class="panel panel-default table-responsive">
                    <table id="products"
                           class="tablesorter-bootstrap table table-condensed table-striped">
                        <thead>
                        <tr>
                            <th>Name</th>
                            <th>Description</th>
                            <th>URL</th>
                            <th>Category</th>
                        </tr>
                        </thead>
                        <tbody>
                        {% for conf in confs %}
                            <tr>
                                <td>
                                    {% if "dojo.change_tool_configuration"|has_configuration_permission:request %}
                                        <a href="{% url 'edit_tool_config' conf.id %}"><b>{{ conf.name }}</b></a>
                                    {% else %}
                                        {{ conf.name }}
                                    {% endif %}
                                </td>
                                <td>
                                    {% if conf.description %}{{ conf.description }}{% endif %}
                                </td>
                                <td>
                                    {% if conf.url %}{{ conf.url }}{% endif %}
                                </td>
                                <td>
                                  {{ conf.tool_type.name }}
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                </div>
                <div class="clearfix">
                    {% include "dojo/paging_snippet.html" with page=confs page_size=True %}
                </div>
            {% else %}
                <p class="text-center">No tool configurations found.</p>
            {% endif %}
        </div>
    </div>
{% endblock %}
{% block postscript %}
    {{ block.super }}
    {% include "dojo/filter_js_snippet.html" %}
{% endblock %}
